export * from './validator'
export * from './check'

export const datetimeShortcuts = [
	{
		text: '今天',
		value() {
			const now = new Date()
			const start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '昨天',
		value: () => {
			const now = new Date()
			const start = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '本周',
		value() {
			const now = new Date()
			const date = new Date(now.getTime())
			const w = date.getDay() || 7
			date.setDate(date.getDate() - w + 1)
			const start = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '上周',
		value() {
			const now = new Date()
			const date = new Date(now.getTime())
			const w = date.getDay() || 7
			date.setDate(date.getDate() - w + 1 - 7)
			const start = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
			const end = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 7, 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '本月',
		value() {
			const now = new Date()
			const start = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '上月',
		value() {
			const now = new Date()
			const start = new Date(now.getFullYear(), now.getMonth() - 1, 1, 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '上上月',
		value() {
			const now = new Date()
			const start = new Date(now.getFullYear(), now.getMonth() - 2, 1, 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth() - 1, 1, 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '最近7天',
		value() {
			const now = new Date()
			const start = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 6, 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '最近30天',
		value() {
			const now = new Date()
			const start = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 29, 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0)
			return [start, end]
		}
	},
	{
		text: '最近60天',
		value() {
			const now = new Date()
			const start = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 59, 0, 0, 0)
			const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0)
			return [start, end]
		}
	}
]
